﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace ChoJu.Converters.Uc
{
    public class DelayColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            long val = 0;
            var bol = long.TryParse(value?.ToString(), out val);
            if (bol == false)
                return Brushes.Red;

            if (val > 0 & val <= 100)
            {
                Color color = (Color)ColorConverter.ConvertFromString("#149602");
                return new SolidColorBrush(color);
            }
            else if (100 < val & val <= 300)
            {
                Color color = (Color)ColorConverter.ConvertFromString("#CE9803");
                return new SolidColorBrush(color);
            }
            else
            {
                Color color = (Color)ColorConverter.ConvertFromString("#D65001");
                return new SolidColorBrush(color);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
